package bank;

import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

@SuppressWarnings("serial")
public class Bank extends UnicastRemoteObject implements IBankmanager {

  public static int blz = 55555555;

  protected Bank() throws RemoteException {
    super();
    kontoEinrichten();
    kontoEinrichten();
  }

  @Override
  public String kontoEinrichten() throws RemoteException {
    return KontoDB.SINGLETON.kontoEinrichten();
  }

  public static void main(String[] args) {

    try {
      LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
    } catch (RemoteException ex) {
      System.out.println(ex.getMessage());
    }

    try {
      Naming.rebind("" + blz, new Bank());
      System.out.println("Bank: " + blz + " works!!!");
    } catch (Exception ex) {
      ex.printStackTrace();
    }

  }

}
